<template>
	<view>
		<u-navbar back-icon-color="#fff"  title-color="#fff"  :border-bottom="false">
		<view slot="content" class="detailSelect">
			<view class="uni-list-cell-db" @click="show=!show">
				<view class="uni-input">{{selector.organizeName}}</view>
				<my-icon name="xiajiantou_biaotilan"></my-icon>
				<u-picker mode="selector" v-model="show" @confirm="confirm" :default-selector="[0]" range-key="organizeName" :range="organizeData">
				</u-picker>
			 </view>
		</view>
		</u-navbar>
		<my-empty  v-if="empyFalse" emptyTit="暂无数据"></my-empty>
		<my-user-li v-for="(item,index) in userList" :key="index" :infoName='item.username' :thumbnail='item.avatar' @click.native="linkDeatil(item.userid)" >
			<template slot="nameBot">
			<view class="name_bot_txt">
				<view class="name_line">学习总时长：<text class="yellow">{{item.times}}</text>分钟</view>
			</view>
			</template>
		</my-user-li>
		<!-- <u-loadmore v-if="userList.length!=0" icon-type="flower" bg-color="#FFFFFF" :status="status" @loadmore="getList()" :margin-top="20" /> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				organizeData:[],//班级数据
			  selector:{},//选中的数据
				show:false,//下拉显示
				userList:[],//练习情况
				pageNo: 1,//当前页数
				isLastPage: false,//是否最后一页
				status: 'loadmore',
				userId:'',
				empyFalse:false
			}
		},
		onLoad(option){
			this.userId=option.userId
			this.getOragnize()
			// this.init()
		},
		computed:{
			lastItem(){
			  return function (value) {
					 if(value){
						return  '最近一次练习：'+value
					 }
			  }
			}
		},
		methods: {
			init(){
				// this.status = 'loadmore';
				// this.pageNo=1;
				// this.isLastPage=false;
				// this.userList=[];//练习情况
				return this.getList();
			},
			// 获取班级
			getOragnize(){
				return new Promise((resolve, reject) => {
					this.request
						.get('/app/teacher/examanalysis/getClassCode',)
						.then(res => {
								this.organizeData=res;
								this.selector=res[0];//默认选中第一个
								this.getList()
							resolve();
						})
						.catch(reject)
				});
			},
			linkDeatil(userId){
				//跳转详情列表
				uni.navigateTo({
					url:'studyList?userId='+userId
				})
			},
			// 获取列表
			getList(){
				const code=this.selector
				return new Promise((resolve, reject) => {
					this.request
						.get(`/app/teacher/home/studyProcess/${this.selector.organizeCode}`)
						.then(res => {
							 this.userList=res;
							 console.log(this.userList,111)
							 this.empyFalse=this.userList.length>0?false:true
							resolve();
						})
						.catch(reject)
				});
			},
			//确认选择
      confirm: function(e){
				this.selector=this.organizeData[e]
					this.getList()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.paper-item:last-child{
		border-bottom: none!important;
	}
.name_bot_txt{
		display: flex;
		justify-content: start;
		margin-top: 15upx;
		width: 100%;
		.name_line{
			width: 100%;
			display: flex;
			justify-content: start;
			align-items: center;
			color: #A6A6A6;
		}
		text{
			display: block;
			height: 35upx;
			overflow: hidden;
		}
	}
</style>
